import React, { memo, useEffect, useState } from 'react'
import HYRequest from '@/services'
const Home = memo(() => {
  // 定义状态 setHighScore存到这里,highScore就能拿到对应的数据
  const [highScore, setHighScore] = useState({})

  // 网络请求
  useEffect(() => {
    HYRequest.get({ url: '/home/highscore' }).then(res => {
      console.log(res)
      setHighScore(res)
    })
  }, [])

  return (
    <div>
      <h2>{highScore.title}</h2>
      <h3>{highScore.subtitle}</h3>
      <ul>
        {highScore.list?.map(item => {
          return <li key={item.id}>{item.name}</li>
        })}
      </ul>
    </div>
  )
})

export default Home